// MFunction.h: Definition of the CMFunction class
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_MFUNCTION_H__1B6ED7CE_EB38_11D1_BF0B_0000B4560A15__INCLUDED_)
#define AFX_MFUNCTION_H__1B6ED7CE_EB38_11D1_BF0B_0000B4560A15__INCLUDED_

#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000

#include "resource.h"       // main symbols

/////////////////////////////////////////////////////////////////////////////
// CMFunction

class CMFunction : 
	public CComDualImpl<IMFunction, &IID_IMFunction, &LIBID_MUDOSLib>, 
	public ISupportErrorInfo,
	public CComObjectRoot,
	public CComCoClass<CMFunction,&CLSID_MFunction>
{
private:
	int       index;
	CComObject<CMValue> *ret;
	CComObject<CMValue> *param[16];
	CComObject<CMProgram> *ob;
	int       m_id;
public:
	CMFunction() {ob=NULL;index=0;ret=NULL;}
	void Create(CMProgram *p,int id)
	{
		if(ob)ob->Release();

		ob=new CComObject<CMProgram>;
		ob->AddRef();
		ob->Assign(p);
		m_id=id;
	}
	~CMFunction() {
		if(ob)ob->Release();
		if(ret)ret->Release();
		if(index)ClearParam();
	}
BEGIN_COM_MAP(CMFunction)
	COM_INTERFACE_ENTRY(IDispatch)
	COM_INTERFACE_ENTRY(IMFunction)
	COM_INTERFACE_ENTRY(ISupportErrorInfo)
END_COM_MAP()
//DECLARE_NOT_AGGREGATABLE(CMFunction) 
// Remove the comment from the line above if you don't want your object to 
// support aggregation. 

DECLARE_REGISTRY(CMFunction, _T("Mudos.MFunction.1"), _T("Mudos.MFunction"), IDS_MFUNCTION_DESC, THREADFLAGS_BOTH)
// ISupportsErrorInfo
	STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid);

// IMFunction
public:
	STDMETHOD(Apply)();
	STDMETHOD(get_Ret)(/*[out, retval]*/ IMValue * *pVal);
	STDMETHOD(ClearParam)();
	STDMETHOD(AddParam)(/*[in]*/ IMValue * pVal);
	STDMETHOD(get_ParamCount)(/*[out, retval]*/ int *pVal);
	STDMETHOD(get_Name)(/*[out, retval]*/ BSTR *pVal);
};

#endif // !defined(AFX_MFUNCTION_H__1B6ED7CE_EB38_11D1_BF0B_0000B4560A15__INCLUDED_)
